//
//  HJDTextViewLbl.m
//  JYHospital
//
//  Created by 胡金东 on 16/5/12.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "HJDTextViewLbl.h"


@interface HJDTextViewLbl ()

@property (nonatomic,weak) UILabel *placeHolderLabel;

@end

@implementation HJDTextViewLbl

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.font = [UIFont systemFontOfSize:12];
        
    }
    return self;
}

-(UILabel *)placeHolderLabel
{
    if (_placeHolderLabel == nil) {
        UILabel * label = [[UILabel alloc]init];
        label.numberOfLines = 0;
        label.textColor = [UIColor getColorWithHexNumber:@"C6C6C6"];
        [self addSubview:label];
        _placeHolderLabel = label;
    }
    return _placeHolderLabel;
}

-(void)setFont:(UIFont *)font
{
    [super setFont:font];
    self.placeHolderLabel.font = font;
    [self.placeHolderLabel sizeToFit];
}

-(void)setPlaceHolder:(NSString *)placeHolder
{
    _placeHolder = placeHolder;
    self.placeHolderLabel.text = placeHolder;
//    设置label的尺寸根文字一样
    [self.placeHolderLabel sizeToFit];
}

-(void)setHidePlaceHolder:(BOOL)hidePlaceHolder
{
    _hidePlaceHolder = hidePlaceHolder;
    self.placeHolderLabel.hidden = hidePlaceHolder;
}

-(void)layoutSubviews
{
    self.placeHolderLabel.x = 10;
    self.placeHolderLabel.y = 8;
    self.placeHolderLabel.width = HJDWidth - HJDVerticalMargin * 2 -10;
}



@end
